package com.aikg.kgrag_java.controller;

import com.aikg.kgrag_java.common.Result;
import com.aikg.kgrag_java.service.ProjectService;
import com.aikg.kgrag_java.service.impl.ProjectServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping()
public class ProjectController {

    @Resource
    private ProjectServiceImpl projectServiceImpl;

    /**
     * 删除领域，删除领域下的所有知识库、文件、索引库  neo4j节点
     * @param projectId 领域id
     * @return 领域id
     */
    @PostMapping("/deleteProject")
    public Result<Integer> deleteProject(Integer projectId){
        if ( projectId == null || projectId < 0) {
            return Result.buildErrorResult("参数错误");
        }
        boolean b = projectServiceImpl.deleteProject(projectId);
        if (b) {
            return Result.buildSuccessResultWithData(projectId);
        }else {
            return Result.buildErrorResult("删除失败");
        }
    }
}
